/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package IO;

/**
 *
 * @author Eagle
 */
public class linkInfoClass {

        private int preCellId,postCellId,grpId,grpSize;
        int splitId1,splitId2;

        int pre(){
            return preCellId;
        }
        int post(){
            return postCellId;
        }
        int grpSize(){
            return grpSize;
        }
        int groupId(){
            return grpId;
        }

        int splitGrpId1(){
            return splitId1;
        }

        int splitGrpId2(){
            return splitId2;
        }


    linkInfoClass(int link, int dgrp, int tgrp, int qgrp){

        if (link<dgrp*2){
            preCellId=link;
            grpId=link/2;
            splitId1=-1;
            splitId2=-1;
//            switch (link%2) {
//                case 1:
//                    postCellId=--link;
//                    break;
//                case 0:
//                    postCellId=++link;
//                    break;
//            }
//            grpSize=2;

        }
        else if(link < dgrp * 2 + tgrp * 6)
        {
            int cellsn=link-dgrp*2;
            grpId=cellsn/6+dgrp;
            splitId1=grpId-dgrp;
            splitId2=-1;
            int postkey=cellsn;
            cellsn=(int) Math.floor(cellsn/2);

            cellsn+=dgrp*2;
            preCellId=cellsn;
//            switch (postkey%6) {
//                case 0:
//                case 3:
//                    postCellId=++cellsn;
//                    break;
//                case 2:
//                case 5:
//                    postCellId=--cellsn;
//                    break;
//                case 1:
//                    postCellId=cellsn+2;
//                    break;
//                case 4:
//                    postCellId=cellsn-2;
//                    break;
//            }
//            grpSize=3;
        }
        else {
            int cellsn=link-dgrp*2-tgrp*6;
            int splitbase;
            grpId=cellsn/12+dgrp+tgrp;
            splitbase=grpId-dgrp-tgrp;
            splitbase*=4;
            splitbase+=tgrp;
            int postkey=cellsn;
            cellsn=(int) Math.floor(cellsn/3);
            int Cellbit=(int)Math.pow(2, cellsn%4);
            int postCellbit=0;
            cellsn+=dgrp*2+tgrp*3;
            preCellId=cellsn;
            switch (postkey%12) {
                case 3:
                case 6:
                case 9:
                    postCellbit=1;
                    break;
                case 0:
                case 7:
                case 10:
                    postCellbit=2;
                    break;
                case 1:
                case 4:
                case 11:
                    postCellbit=4;
                    break;
                case 2:
                case 5:
                case 8:
                    postCellbit=8;
                    break;
            }
//            grpSize=4;

            if (Cellbit+postCellbit==3){
                splitId1=splitbase;
                splitId2=splitbase+1;
            }
            else if (Cellbit + postCellbit == 5) {
                splitId1=splitbase;
                splitId2=splitbase+2;
            }
            else if (Cellbit + postCellbit == 9) {
                splitId1=splitbase+1;
                splitId2=splitbase+2;
            }
            else if (Cellbit + postCellbit == 6) {
                splitId1=splitbase+3;
                splitId2=splitbase;
            }
            else if (Cellbit + postCellbit == 10) {
                splitId1=splitbase+3;
                splitId2=splitbase+1;
            }
            else if (Cellbit + postCellbit == 12) {
                splitId1=splitbase+2;
                splitId2=splitbase+3;
            }
            
        }
    }



}
